using System;
using System.Collections.Generic;
using UnityEngine;

public class GameHelper
{
	public static string[] name_animation = new string[11]
	{
		AnimationName.player_shoot_layup_throw,
		AnimationName.player_shoot_dunk_close_onehand,
		AnimationName.player_shoot_dunk_far_onehand,
		AnimationName.player_shoot_dunk_back,
		AnimationName.player_shoot_layup_back,
		AnimationName.player_shoot_dunk_close_twohand,
		AnimationName.player_shoot_layup_eurostep,
		AnimationName.player_shoot_dunk_turnaround,
		AnimationName.player_shoot_dunk_crossleg,
		AnimationName.player_shoot_layup_turnaround,
		AnimationName.player_shoot_dunk_crossleg2
	};

	public static float[] shootDistancePercent = new float[7]
	{
		25f,
		40f,
		60f,
		10f,
		0f,
		-20f,
		-40f
	};

	public static float[] chargeFoulPercent = new float[6]
	{
		4f,
		8f,
		12f,
		16f,
		20f,
		24f
	};

	public static float[] stealFoulPercent = new float[6]
	{
		4f,
		8f,
		12f,
		16f,
		20f,
		24f
	};

	public static float[] blockFoulPercent = new float[6]
	{
		4f,
		8f,
		12f,
		16f,
		20f,
		24f
	};

	public static int[] D_add = new int[7]
	{
		2,
		3,
		2,
		3,
		2,
		3,
		2
	};

	public static int[] C_add = new int[7]
	{
		2,
		3,
		2,
		3,
		2,
		3,
		2
	};

	public static int[] B_add = new int[7]
	{
		3,
		4,
		3,
		4,
		3,
		4,
		3
	};

	public static int[] A_add = new int[7]
	{
		4,
		4,
		4,
		4,
		4,
		4,
		4
	};

	public static int[] Legend_add = new int[7]
	{
		2,
		3,
		4,
		5,
		6,
		7,
		8
	};

	public static int[] Star_add = new int[7]
	{
		3,
		4,
		5,
		3,
		4,
		5,
		4
	};

	public static List<int> indexHaveTeam_East = new List<int>();

	public static List<int> indexHaveTeam_West = new List<int>();

	public static int[] quickplay_para_level = new int[32];

	private static int[] rateA_IndexInTeamData;

	private static int[] rateB_IndexInTeamData;

	private static int[] rateC_IndexInTeamData;

	private static int[] rateD_IndexInTeamData;

	private static int[] rateS_IndexInTeamData;

	public static void StandardPlayerPos(ref Vector3 pos)
	{
		pos.x = Mathf.Clamp(pos.x, -7.49f, 7.49f);
		pos.z = Mathf.Clamp(pos.z, -13.9f, 13.9f);
		pos.y = Mathf.Clamp(pos.y, 0f, 20f);
	}

	public static void StandardBallPos(ref Vector3 pos)
	{
		pos.x = Mathf.Clamp(pos.x, -8.49f, 8.49f);
		pos.z = Mathf.Clamp(pos.z, -14.9f, 14.9f);
		pos.y = Mathf.Clamp(pos.y, 0f, 20f);
	}

	public static bool IsOutside(Vector3 pos)
	{
		if (Mathf.Abs(pos.x) >= 7.5f)
		{
			return true;
		}
		if (Mathf.Abs(pos.z) >= 14f)
		{
			return true;
		}
		return false;
	}

	public static bool IsInThreePointArea(Vector3 myPos, bool isLeft)
	{
		if (isLeft)
		{
			return MathHelper.getSqrDistance(myPos, Global.posBallIn_Left_Ground) > 52.5625f;
		}
		return MathHelper.getSqrDistance(myPos, Global.posBallIn_Right_Ground) > 52.5625f;
	}

	public static Vector2 WorldPosToGirdPos(Vector3 pos)
	{
		return new Vector2(13f - Mathf.Floor(pos.z), (int)(6.5f - Mathf.Floor(pos.x)));
	}

	public static Vector3 GirdPosToWorldPos(Vector2 pos)
	{
		return new Vector3(7.5f - pos.y, 0f, 14f - pos.x);
	}

	public static bool IsInSameGird(Vector3 pos1, Vector3 pos2)
	{
		return MathHelper.isVector2Equal(WorldPosToGirdPos(pos1), WorldPosToGirdPos(pos2));
	}

	public static void checkUnlockClothe()
	{
		for (int i = 0; i < 5; i++)
		{
			if (getMaxLevel_AllTeam() >= (i + 1) * 2)
			{
				GameData.IsUnlockClothe[i] = true;
			}
			else
			{
				GameData.IsUnlockClothe[i] = false;
			}
		}
	}

	public static string getActionAnimationName(int indexOfTeamManage)
	{
		return name_animation[indexOfTeamManage];
	}

	public static void checkUnlockAction()
	{
		if (getMaxLevel_AllTeam() >= 10)
		{
			GameData.IsUnlockAction[0] = true;
			GameData.IsUnlockAction[1] = true;
			GameData.IsUnlockAction[2] = true;
			GameData.IsUnlockAction[3] = true;
		}
		else if (getMaxLevel_AllTeam() >= 9)
		{
			GameData.IsUnlockAction[0] = true;
			GameData.IsUnlockAction[1] = true;
			GameData.IsUnlockAction[2] = true;
			GameData.IsUnlockAction[3] = false;
		}
		else if (getMaxLevel_AllTeam() >= 3)
		{
			GameData.IsUnlockAction[0] = true;
			GameData.IsUnlockAction[1] = true;
			GameData.IsUnlockAction[2] = false;
			GameData.IsUnlockAction[3] = false;
		}
		else if (getMaxLevel_AllTeam() >= 2)
		{
			GameData.IsUnlockAction[0] = true;
			GameData.IsUnlockAction[1] = false;
			GameData.IsUnlockAction[2] = false;
			GameData.IsUnlockAction[3] = false;
		}
		else
		{
			GameData.IsUnlockAction[0] = false;
			GameData.IsUnlockAction[1] = false;
			GameData.IsUnlockAction[2] = false;
			GameData.IsUnlockAction[3] = false;
		}
	}

	public static void checkUnlockBall()
	{
		if (getMaxLevel_AllTeam() >= 9)
		{
			GameData.IsUnlockBall[1] = true;
			GameData.IsUnlockBall[2] = true;
		}
		else if (getMaxLevel_AllTeam() >= 5 && getMaxLevel_AllTeam() <= 5)
		{
			GameData.IsUnlockBall[1] = true;
			GameData.IsUnlockBall[2] = false;
		}
	}

	public static bool MoveTo(Player player, Vector3 targetPos, float speed, bool isLookAtTargetPos)
	{
		if (isReachTargetPos(player, targetPos))
		{
			return true;
		}
		if (!MathHelper.isVector3Equal(targetPos, player.bassline_targetPos) && MathHelper.getSqrDistance_vec2(Instance<Ball>.instance.getPosition(), targetPos) > 0.1f)
		{
			StandardPlayerPos(ref targetPos);
		}
		if (isLookAtTargetPos)
		{
			player.LookAtSmooth(targetPos);
		}
		if (!Physics.Raycast(MathHelper.setY(player.getPosition(), 1f), targetPos - player.getPosition(), 0.9f) || player.isRootMotion)
		{
			player.setPositon(Vector3.MoveTowards(player.getPosition(), targetPos, Time.fixedDeltaTime * speed));
		}
		else
		{
			if (player.timeGoRight > 1f || (player.timeGoRight > -1f && player.timeGoRight <= 0f))
			{
				player.timeGoRight -= Time.fixedDeltaTime;
				targetPos = player.getPosition() + player.myTransform.right;
			}
			else if (player.timeGoRight <= 1f && player.timeGoRight > 0f)
			{
				targetPos = player.getPosition() - player.myTransform.right;
				player.timeGoRight -= Time.fixedDeltaTime;
			}
			else if (player.timeGoRight <= -1f)
			{
				player.timeGoRight = UnityEngine.Random.Range(1f, 5f);
				if (MathHelper.getSqrDistance(player.getPosition(), targetPos) <= 1f)
				{
					return true;
				}
			}
			if (!MathHelper.isVector3Equal(targetPos, player.bassline_targetPos) && MathHelper.getSqrDistance_vec2(Instance<Ball>.instance.getPosition(), targetPos) > 0.1f)
			{
				StandardPlayerPos(ref targetPos);
			}
			player.setPositon(Vector3.MoveTowards(player.getPosition(), targetPos, Time.fixedDeltaTime * speed));
		}
		return false;
	}

	public static bool isReachTargetPos(Player player, Vector3 targetPos)
	{
		if (MathHelper.getSqrDistance_vec2(player.getPosition(), targetPos) < 0.1f)
		{
			return true;
		}
		return false;
	}

	public static bool MoveTo(Referee referee, Vector3 targetPos, float speed, bool isLookAtTargetPos)
	{
		if (MathHelper.isVector3Equal(referee.getPosition(), targetPos))
		{
			return true;
		}
		if (isLookAtTargetPos)
		{
			referee.LookAt(targetPos);
		}
		referee.setPositon(Vector3.MoveTowards(referee.getPosition(), targetPos, Time.fixedDeltaTime * speed));
		return false;
	}

	public static bool MoveTo(Transform ball, Vector3 targetPos, float speed)
	{
		if (MathHelper.isVector3Equal(ball.position, targetPos))
		{
			return true;
		}
		StandardBallPos(ref targetPos);
		ball.position = Vector3.MoveTowards(ball.position, targetPos, Time.fixedDeltaTime * speed);
		return false;
	}

	public static bool RotateTo(Transform trans, Vector3 targetAngle, float speed)
	{
		if (MathHelper.isVector3Equal(trans.eulerAngles, targetAngle))
		{
			return true;
		}
		trans.eulerAngles = Vector3.RotateTowards(trans.eulerAngles, targetAngle, 10f, speed);
		return false;
	}

	public static int getShootDistanceArea(float distance)
	{
		if (distance > 5f && distance <= 7.25f)
		{
			return 1;
		}
		if (distance > 2.5f && distance <= 5f)
		{
			return 2;
		}
		if (distance <= 2.5f)
		{
			return 3;
		}
		if (distance > 7.25f && distance <= 9f)
		{
			return 4;
		}
		if (distance > 9f && distance <= 11f)
		{
			return 5;
		}
		if (distance > 11f && distance <= 13f)
		{
			return 6;
		}
		if (distance > 13f)
		{
			return 7;
		}
		UnityEngine.Debug.LogError("not find distance");
		return 0;
	}

	public static int getDailyBonusTeamIndex()
	{
		if (GameData.CurrentMonth >= getRateATeam().Length || GameData.CurrentMonth < 0)
		{
			GameData.CurrentMonth = 0;
		}
		return getRateATeam()[GameData.CurrentMonth];
	}

	public static int[] getData(string rate, int level, int index)
	{
		if (rate == "D")
		{
			return getDataWillBe(level, index, D_add);
		}
		if (rate == "C")
		{
			return getDataWillBe(level, index, C_add);
		}
		if (rate == "B")
		{
			return getDataWillBe(level, index, B_add);
		}
		if (rate == "A")
		{
			return getDataWillBe(level, index, A_add);
		}
		if (index == 30)
		{
			return getDataWillBe(level, index, Legend_add);
		}
		return getDataWillBe(level, index, Star_add);
	}

	public static int[] getIncreaseData(string rate, int level, int index)
	{
		int[] array = new int[8];
		int[] array2 = (rate == "D") ? getDataWillBe(level, index, D_add) : ((rate == "C") ? getDataWillBe(level, index, C_add) : ((rate == "B") ? getDataWillBe(level, index, B_add) : ((rate == "A") ? getDataWillBe(level, index, A_add) : ((index != 30) ? getDataWillBe(level, index, Star_add) : getDataWillBe(level, index, Legend_add)))));
		for (int i = 0; i < 8; i++)
		{
			array[i] = array2[i] - getData(rate, level - 1, index)[i];
		}
		array[3] = 0;
		array[7] = 0;
		switch (level)
		{
		case 9:
			array[3] = 1;
			if (rate == "C" || rate == "D")
			{
				array[7] = 1;
			}
			break;
		case 10:
			array[7] = 1;
			if (rate == "C" || rate == "D")
			{
				array[3] = 1;
			}
			break;
		}
		return array;
	}

	private static int[] getDataWillBe(int level, int index, int[] rate_add)
	{
		TeamData teamData = LoadData.teamDatas[index];
		string data_rate = teamData.data_rate;
		float[] array = new float[8]
		{
			teamData.data_point2,
			teamData.data_point3,
			teamData.data_pass,
			teamData.data_speed,
			teamData.data_rebound,
			teamData.data_steal,
			teamData.data_block,
			teamData.data_physical
		};
		for (int i = 2; i <= level; i++)
		{
			if (i <= 8)
			{
				for (int j = 0; j < 8; j++)
				{
					if (teamData.data_type == 1)
					{
						switch (j)
						{
						case 0:
						case 1:
							array[j] += (float)rate_add[i - 2] + (float)rate_add[i - 2] * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[j] += (float)rate_add[i - 2] - (float)rate_add[i - 2] * 0.15f;
							break;
						default:
							array[j] += rate_add[i - 2];
							break;
						}
					}
					else if (teamData.data_type == 2)
					{
						switch (j)
						{
						case 0:
						case 1:
							array[j] += (float)rate_add[i - 2] - (float)rate_add[i - 2] * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[j] += (float)rate_add[i - 2] + (float)rate_add[i - 2] * 0.15f;
							break;
						default:
							array[j] += rate_add[i - 2];
							break;
						}
					}
					else if (teamData.data_type == 3)
					{
						array[j] += (float)rate_add[i - 2] + (float)rate_add[i - 2] * 0.1f;
					}
				}
				continue;
			}
			switch (i)
			{
			case 9:
				if (data_rate == "S" && index == 30)
				{
					for (int m = 0; m < 8; m++)
					{
						if (teamData.data_type == 1)
						{
							switch (m)
							{
							case 0:
							case 1:
								array[m] += 17.25f;
								break;
							case 4:
							case 5:
							case 6:
								array[m] += 12.75f;
								break;
							default:
								array[m] += 15f;
								break;
							}
						}
						else if (teamData.data_type == 2)
						{
							switch (m)
							{
							case 0:
							case 1:
								array[m] += 12.75f;
								break;
							case 4:
							case 5:
							case 6:
								array[m] += 17.25f;
								break;
							default:
								array[m] += 15f;
								break;
							}
						}
						else if (teamData.data_type == 3)
						{
							array[m] += 16.5f;
						}
					}
					break;
				}
				for (int n = 0; n < 8; n++)
				{
					if (teamData.data_type == 1)
					{
						switch (n)
						{
						case 0:
						case 1:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f + (float)getData(data_rate, 8, index)[n] * 0.3f * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f - (float)getData(data_rate, 8, index)[n] * 0.3f * 0.15f;
							break;
						default:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f;
							break;
						}
					}
					else if (teamData.data_type == 2)
					{
						switch (n)
						{
						case 0:
						case 1:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f - (float)getData(data_rate, 8, index)[n] * 0.3f * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f + (float)getData(data_rate, 8, index)[n] * 0.3f * 0.15f;
							break;
						default:
							array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f;
							break;
						}
					}
					else if (teamData.data_type == 3)
					{
						array[n] += (float)getData(data_rate, 8, index)[n] * 0.3f + (float)getData(data_rate, 8, index)[n] * 0.3f * 0.1f;
					}
				}
				break;
			case 10:
				if (data_rate == "S" && index == 30)
				{
					for (int k = 0; k < 8; k++)
					{
						if (teamData.data_type == 1)
						{
							switch (k)
							{
							case 0:
							case 1:
								array[k] += 320f;
								break;
							case 4:
							case 5:
							case 6:
								array[k] += 17f;
								break;
							default:
								array[k] += 20f;
								break;
							}
						}
						else if (teamData.data_type == 2)
						{
							switch (k)
							{
							case 0:
							case 1:
								array[k] += 17f;
								break;
							case 4:
							case 5:
							case 6:
								array[k] += 23f;
								break;
							default:
								array[k] += 20f;
								break;
							}
						}
						else if (teamData.data_type == 3)
						{
							array[k] += 22f;
						}
					}
					break;
				}
				for (int l = 0; l < 8; l++)
				{
					if (teamData.data_type == 1)
					{
						switch (l)
						{
						case 0:
						case 1:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f + (float)getData(data_rate, 9, index)[l] * 0.5f * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f - (float)getData(data_rate, 9, index)[l] * 0.5f * 0.15f;
							break;
						default:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f;
							break;
						}
					}
					else if (teamData.data_type == 2)
					{
						switch (l)
						{
						case 0:
						case 1:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f - (float)getData(data_rate, 9, index)[l] * 0.5f * 0.15f;
							break;
						case 4:
						case 5:
						case 6:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f + (float)getData(data_rate, 9, index)[l] * 0.5f * 0.15f;
							break;
						default:
							array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f;
							break;
						}
					}
					else if (teamData.data_type == 3)
					{
						array[l] += (float)getData(data_rate, 9, index)[l] * 0.5f + (float)getData(data_rate, 9, index)[l] * 0.5f * 0.1f;
					}
				}
				break;
			}
		}
		array[3] = teamData.data_speed;
		array[7] = teamData.data_physical;
		switch (level)
		{
		case 9:
			array[3] += 1f;
			if (data_rate == "C" || data_rate == "D")
			{
				array[7] += 1f;
			}
			break;
		case 10:
			array[3] += 1f;
			if (data_rate == "C" || data_rate == "D")
			{
				array[7] += 1f;
			}
			array[7] += 1f;
			if (data_rate == "C" || data_rate == "D")
			{
				array[3] += 1f;
			}
			break;
		}
		return new int[8]
		{
			(int)Mathf.Round(array[0]),
			(int)Mathf.Round(array[1]),
			(int)Mathf.Round(array[2]),
			(int)Mathf.Round(array[3]),
			(int)Mathf.Round(array[4]),
			(int)Mathf.Round(array[5]),
			(int)Mathf.Round(array[6]),
			(int)Mathf.Round(array[7])
		};
	}

	public static int getMaxLevel_AllTeam()
	{
		int num = 0;
		if (getMaxLevel_BalanceTeam() > num)
		{
			num = getMaxLevel_BalanceTeam();
		}
		if (getMaxLevel_ControlTeam() > num)
		{
			num = getMaxLevel_ControlTeam();
		}
		if (getMaxLevel_OffensiveTeam() > num)
		{
			num = getMaxLevel_OffensiveTeam();
		}
		return num;
	}

	public static int getMaxLevel_OffensiveTeam()
	{
		int num = 1;
		for (int i = 0; i < 32; i++)
		{
			if (isUserHaveTeam(i) && LoadData.teamDatas[i].data_type == 1 && GameData.TeamLevel[i] > num)
			{
				num = GameData.TeamLevel[i];
			}
		}
		return num;
	}

	public static int getMaxLevel_ControlTeam()
	{
		int num = 1;
		for (int i = 0; i < 32; i++)
		{
			if (isUserHaveTeam(i) && LoadData.teamDatas[i].data_type == 2 && GameData.TeamLevel[i] > num)
			{
				num = GameData.TeamLevel[i];
			}
		}
		return num;
	}

	public static int getMaxLevel_BalanceTeam()
	{
		int num = 1;
		for (int i = 0; i < 32; i++)
		{
			if (isUserHaveTeam(i) && LoadData.teamDatas[i].data_type == 3 && GameData.TeamLevel[i] > num)
			{
				num = GameData.TeamLevel[i];
			}
		}
		return num;
	}

	public static void resetUserHaveTeam()
	{
		indexHaveTeam_East.Clear();
		indexHaveTeam_West.Clear();
		for (int i = 0; i < 32; i++)
		{
			if (isUserHaveTeam(i) || i == 0)
			{
				if (i < 15)
				{
					indexHaveTeam_East.Add(i);
					continue;
				}
				if (i >= 15 && i < 30)
				{
					indexHaveTeam_West.Add(i);
					continue;
				}
				indexHaveTeam_East.Add(i);
				indexHaveTeam_West.Add(i);
			}
		}
	}

	public static bool isCardTooMuch(int cardCount, int index)
	{
		if (GameData.TeamLevel[index] == 10)
		{
			return true;
		}
		int num = 0;
		for (int i = GameData.TeamLevel[index] - 1; i < 9; i++)
		{
			num += Global.card_upgrade_total[i];
		}
		if (cardCount > num)
		{
			return true;
		}
		return false;
	}

	public static int[] getCards_NormalPackage()
	{
		int[] array = new int[10]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		if (!GameData.IsFinishTutorial)
		{
			bool flag;
			bool flag2;
			do
			{
				for (int i = 0; i < 10; i++)
				{
					array[i] = -1;
				}
				array[0] = getRateDTeam()[UnityEngine.Random.Range(0, getRateDTeam().Length)];
				int num5 = getRateDTeam()[UnityEngine.Random.Range(0, getRateDTeam().Length)];
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateDTeam()[UnityEngine.Random.Range(0, getRateDTeam().Length)];
				}
				array[1] = num5;
				num5 = getRateDTeam()[UnityEngine.Random.Range(0, getRateDTeam().Length)];
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateDTeam()[UnityEngine.Random.Range(0, getRateDTeam().Length)];
				}
				array[2] = num5;
				array[3] = getRateCTeam()[UnityEngine.Random.Range(0, getRateCTeam().Length)];
				num5 = getRateCTeam()[UnityEngine.Random.Range(0, getRateCTeam().Length)];
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateCTeam()[UnityEngine.Random.Range(0, getRateCTeam().Length)];
				}
				array[4] = num5;
				num5 = getRateCTeam()[UnityEngine.Random.Range(0, getRateCTeam().Length)];
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateCTeam()[UnityEngine.Random.Range(0, getRateCTeam().Length)];
				}
				array[5] = num5;
				array[6] = getRateBTeam()[UnityEngine.Random.Range(0, getRateBTeam().Length)];
				num5 = getRateBTeam()[UnityEngine.Random.Range(0, getRateBTeam().Length)];
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateBTeam()[UnityEngine.Random.Range(0, getRateBTeam().Length)];
				}
				array[7] = num5;
				num5 = 0;
				while (MathHelper.isArrayHaveNum(array, num5))
				{
					num5 = getRateBTeam()[UnityEngine.Random.Range(0, getRateBTeam().Length)];
				}
				array[8] = num5;
				array[9] = num5;
				flag = false;
				flag2 = false;
				for (int j = 0; j < 10; j++)
				{
					if (array[j] < 15)
					{
						flag = true;
						if (flag2)
						{
							break;
						}
					}
					else if (array[j] >= 15 && array[j] < 30)
					{
						flag2 = true;
						if (flag)
						{
							break;
						}
					}
				}
			}
			while (!flag || !flag2 || array[8] != 0);
			return MathHelper.setArrayToRandomOrder(array);
		}
		int num6 = array.Length;
		while (num6 > 0)
		{
			int num7 = UnityEngine.Random.Range(0, 100);
			List<int> list = new List<int>();
			int[] array2;
			if (num7 < 40)
			{
				for (int k = 0; k < getRateDTeam().Length; k++)
				{
					list.Add(GameData.CardsCount[getRateDTeam()[k]]);
				}
				array2 = getRateDTeam();
				num4++;
			}
			else if (num7 >= 40 && num7 < 70)
			{
				for (int l = 0; l < getRateCTeam().Length; l++)
				{
					list.Add(GameData.CardsCount[getRateCTeam()[l]]);
				}
				array2 = getRateCTeam();
				num3++;
			}
			else if (num7 >= 70 && num7 < 90)
			{
				for (int m = 0; m < getRateBTeam().Length; m++)
				{
					list.Add(GameData.CardsCount[getRateBTeam()[m]]);
				}
				array2 = getRateBTeam();
				num2++;
			}
			else
			{
				for (int n = 0; n < getRateATeam().Length; n++)
				{
					list.Add(GameData.CardsCount[getRateATeam()[n]]);
				}
				array2 = getRateATeam();
				num++;
			}
			int[] indexInRankOrder = MathHelper.getIndexInRankOrder(list.ToArray());
			float[] array3 = new float[indexInRankOrder.Length];
			for (int num8 = 0; num8 < indexInRankOrder.Length; num8++)
			{
				if (num8 < indexInRankOrder.Length / 2)
				{
					array3[num8] = 100f / (float)indexInRankOrder.Length - 5f;
				}
				else if (indexInRankOrder.Length % 2 == 0)
				{
					array3[num8] = 100f / (float)indexInRankOrder.Length + 5f;
				}
				else if (num8 != indexInRankOrder.Length / 2)
				{
					array3[num8] = 100f / (float)indexInRankOrder.Length + 5f;
				}
			}
			float num9 = UnityEngine.Random.Range(0f, 100f);
			float num10 = 0f;
			int num11 = 0;
			for (int num12 = 0; num12 < array3.Length; num12++)
			{
				num10 += array3[num12];
				if (num9 < num10)
				{
					num11 = num12;
					break;
				}
			}
			int num13 = UnityEngine.Random.Range(0, array.Length);
			while (array[num13] != -1)
			{
				num13 = UnityEngine.Random.Range(0, array.Length);
			}
			array[num13] = array2[indexInRankOrder[num11]];
			num6--;
			if (num6 == 0 && (num4 < 2 || num4 > 6 || num3 < 1 || num3 > 5 || num2 < 1 || num2 > 4 || num > 3))
			{
				num6 = array.Length;
				num = 0;
				num2 = 0;
				num3 = 0;
				num4 = 0;
				for (int num14 = 0; num14 < 10; num14++)
				{
					array[num14] = -1;
				}
			}
		}
		return array;
	}

	public static int[] getCards_AdvancePackage()
	{
		int[] array = new int[10]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = array.Length;
		while (num6 > 0)
		{
			int num7 = UnityEngine.Random.Range(0, 100);
			List<int> list = new List<int>();
			int[] array2;
			if (num7 < 10)
			{
				for (int i = 0; i < getRateDTeam().Length; i++)
				{
					list.Add(GameData.CardsCount[getRateDTeam()[i]]);
				}
				array2 = getRateDTeam();
				num5++;
			}
			else if (num7 >= 10 && num7 < 27)
			{
				for (int j = 0; j < getRateCTeam().Length; j++)
				{
					list.Add(GameData.CardsCount[getRateCTeam()[j]]);
				}
				array2 = getRateCTeam();
				num4++;
			}
			else if (num7 >= 27 && num7 < 52)
			{
				for (int k = 0; k < getRateBTeam().Length; k++)
				{
					list.Add(GameData.CardsCount[getRateBTeam()[k]]);
				}
				array2 = getRateBTeam();
				num3++;
			}
			else if (num7 >= 52 && num7 < 97)
			{
				for (int l = 0; l < getRateATeam().Length; l++)
				{
					list.Add(GameData.CardsCount[getRateATeam()[l]]);
				}
				array2 = getRateATeam();
				num2++;
			}
			else
			{
				for (int m = 0; m < getRateSTeam().Length; m++)
				{
					list.Add(GameData.CardsCount[getRateSTeam()[m]]);
				}
				array2 = getRateSTeam();
				num++;
			}
			int[] indexInRankOrder = MathHelper.getIndexInRankOrder(list.ToArray());
			float[] array3 = new float[indexInRankOrder.Length];
			for (int n = 0; n < indexInRankOrder.Length; n++)
			{
				if (n < indexInRankOrder.Length / 2)
				{
					array3[n] = 100f / (float)indexInRankOrder.Length - 5f;
				}
				else if (indexInRankOrder.Length % 2 == 0)
				{
					array3[n] = 100f / (float)indexInRankOrder.Length + 5f;
				}
				else if (n != indexInRankOrder.Length / 2)
				{
					array3[n] = 100f / (float)indexInRankOrder.Length + 5f;
				}
			}
			float num8 = UnityEngine.Random.Range(0f, 100f);
			float num9 = 0f;
			int num10 = 0;
			for (int num11 = 0; num11 < array3.Length; num11++)
			{
				num9 += array3[num11];
				if (num8 < num9)
				{
					num10 = num11;
					break;
				}
			}
			int num12 = UnityEngine.Random.Range(0, array.Length);
			while (array[num12] != -1)
			{
				num12 = UnityEngine.Random.Range(0, array.Length);
			}
			array[num12] = array2[indexInRankOrder[num10]];
			num6--;
			if (num6 == 0 && (num5 < 0 || num5 > 2 || num4 < 0 || num4 > 3 || num3 < 1 || num3 > 4 || num2 < 2 || num2 > 5 || num > 3))
			{
				num6 = array.Length;
				num2 = 0;
				num3 = 0;
				num4 = 0;
				num5 = 0;
				num = 0;
				for (int num13 = 0; num13 < 10; num13++)
				{
					array[num13] = -1;
				}
			}
		}
		return array;
	}

	public static bool isUserHaveTeam(int indexInData)
	{
		if (GameData.TeamLevel[indexInData] == 1 && GameData.CardsCount[indexInData] == 0)
		{
			return false;
		}
		return true;
	}

	public static int getUserHaveTeamCount()
	{
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (isUserHaveTeam(i))
			{
				num++;
			}
		}
		return num;
	}

	public static int[] setParaTeam_QuickPlay(int userLevel)
	{
		for (int i = 0; i < quickplay_para_level.Length; i++)
		{
			quickplay_para_level[i] = UnityEngine.Random.Range(userLevel - 3, userLevel + 4);
			quickplay_para_level[i] = Mathf.Clamp(quickplay_para_level[i], 1, 10);
		}
		return quickplay_para_level;
	}

	public static int[] getParaTeam_ShortSeason(int userTeam)
	{
		int[] array = new int[7]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int num = -1;
		int num2 = -1;
		int num3 = -1;
		int num4 = -1;
		do
		{
			num4 = UnityEngine.Random.Range(0, 4);
			num3 = UnityEngine.Random.Range(0, 4);
			num2 = UnityEngine.Random.Range(0, 4);
			if (num2 + num3 + num4 <= 7)
			{
				num = 7 - num2 - num3 - num4;
			}
		}
		while (num < 1 || num > 3);
		int[] rateATeam = getRateATeam();
		for (int i = 0; i < num; i++)
		{
			int num5 = UnityEngine.Random.Range(0, 7);
			while (array[num5] != -1)
			{
				num5 = UnityEngine.Random.Range(0, 7);
			}
			int num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num6) || num6 == userTeam)
			{
				num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			}
			array[num5] = num6;
		}
		int[] rateBTeam = getRateBTeam();
		for (int j = 0; j < num2; j++)
		{
			int num7 = UnityEngine.Random.Range(0, 7);
			while (array[num7] != -1)
			{
				num7 = UnityEngine.Random.Range(0, 7);
			}
			int num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num8) || num8 == userTeam)
			{
				num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			}
			array[num7] = num8;
		}
		int[] rateCTeam = getRateCTeam();
		for (int k = 0; k < num3; k++)
		{
			int num9 = UnityEngine.Random.Range(0, 7);
			while (array[num9] != -1)
			{
				num9 = UnityEngine.Random.Range(0, 7);
			}
			int num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num10) || num10 == userTeam)
			{
				num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			}
			array[num9] = num10;
		}
		int[] rateDTeam = getRateDTeam();
		for (int l = 0; l < num4; l++)
		{
			int num11 = UnityEngine.Random.Range(0, 7);
			while (array[num11] != -1)
			{
				num11 = UnityEngine.Random.Range(0, 7);
			}
			int num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num12) || num12 == userTeam)
			{
				num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			}
			array[num11] = num12;
		}
		return array;
	}

	public static int[] getParaTeam_LongSeason(int userTeam)
	{
		int[] array = new int[7]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int num = -1;
		int num2 = -1;
		int num3 = -1;
		int num4 = -1;
		do
		{
			num4 = UnityEngine.Random.Range(0, 4);
			num3 = UnityEngine.Random.Range(0, 4);
			num2 = UnityEngine.Random.Range(0, 4);
			if (num2 + num3 + num4 <= 7)
			{
				num = 7 - num2 - num3 - num4;
			}
		}
		while (num < 1 || num > 3);
		int[] rateATeam = getRateATeam();
		for (int i = 0; i < num; i++)
		{
			int num5 = UnityEngine.Random.Range(0, 7);
			while (array[num5] != -1)
			{
				num5 = UnityEngine.Random.Range(0, 7);
			}
			int num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num6) || num6 == userTeam)
			{
				num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			}
			array[num5] = num6;
		}
		int[] rateBTeam = getRateBTeam();
		for (int j = 0; j < num2; j++)
		{
			int num7 = UnityEngine.Random.Range(0, 7);
			while (array[num7] != -1)
			{
				num7 = UnityEngine.Random.Range(0, 7);
			}
			int num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num8) || num8 == userTeam)
			{
				num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			}
			array[num7] = num8;
		}
		int[] rateCTeam = getRateCTeam();
		for (int k = 0; k < num3; k++)
		{
			int num9 = UnityEngine.Random.Range(0, 7);
			while (array[num9] != -1)
			{
				num9 = UnityEngine.Random.Range(0, 7);
			}
			int num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num10) || num10 == userTeam)
			{
				num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			}
			array[num9] = num10;
		}
		int[] rateDTeam = getRateDTeam();
		for (int l = 0; l < num4; l++)
		{
			int num11 = UnityEngine.Random.Range(0, 7);
			while (array[num11] != -1)
			{
				num11 = UnityEngine.Random.Range(0, 7);
			}
			int num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num12) || num12 == userTeam)
			{
				num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			}
			array[num11] = num12;
		}
		return array;
	}

	public static int[] getParaTeam_PlayOffs(bool isEast, int userTeam)
	{
		int[] array = new int[7]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int num = -1;
		int num2 = -1;
		int num3 = -1;
		int num4 = -1;
		if (isEast)
		{
			while (true)
			{
				num4 = UnityEngine.Random.Range(0, 3);
				num3 = UnityEngine.Random.Range(1, 4);
				num2 = UnityEngine.Random.Range(1, 4);
				if (num2 + num3 + num4 <= 7)
				{
					num = 7 - num2 - num3 - num4;
				}
				if (LoadData.teamDatas[userTeam].data_rate == "A")
				{
					if (num == 1)
					{
						break;
					}
				}
				else if (num >= 1 && num <= 2)
				{
					break;
				}
			}
		}
		else
		{
			do
			{
				num4 = UnityEngine.Random.Range(0, 3);
				num3 = UnityEngine.Random.Range(1, 3);
				num2 = 1;
				if (num2 + num3 + num4 <= 7)
				{
					num = 7 - num2 - num3 - num4;
				}
			}
			while (num < 1 || num > 3);
		}
		int[] rateATeam = getRateATeam();
		for (int i = 0; i < num; i++)
		{
			int num5 = UnityEngine.Random.Range(0, 7);
			while (array[num5] != -1)
			{
				num5 = UnityEngine.Random.Range(0, 7);
			}
			int num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num6) || num6 == userTeam || LoadData.teamDatas[num6].data_location != Global.str_location[(!isEast) ? 1 : 0])
			{
				num6 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			}
			array[num5] = num6;
		}
		int[] rateBTeam = getRateBTeam();
		for (int j = 0; j < num2; j++)
		{
			int num7 = UnityEngine.Random.Range(0, 7);
			while (array[num7] != -1)
			{
				num7 = UnityEngine.Random.Range(0, 7);
			}
			int num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num8) || num8 == userTeam || LoadData.teamDatas[num8].data_location != Global.str_location[(!isEast) ? 1 : 0])
			{
				num8 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			}
			array[num7] = num8;
		}
		int[] rateCTeam = getRateCTeam();
		for (int k = 0; k < num3; k++)
		{
			int num9 = UnityEngine.Random.Range(0, 7);
			while (array[num9] != -1)
			{
				num9 = UnityEngine.Random.Range(0, 7);
			}
			int num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num10) || num10 == userTeam || LoadData.teamDatas[num10].data_location != Global.str_location[(!isEast) ? 1 : 0])
			{
				num10 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			}
			array[num9] = num10;
		}
		int[] rateDTeam = getRateDTeam();
		for (int l = 0; l < num4; l++)
		{
			int num11 = UnityEngine.Random.Range(0, 7);
			while (array[num11] != -1)
			{
				num11 = UnityEngine.Random.Range(0, 7);
			}
			int num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			while (MathHelper.isArrayHaveNum(array, num12) || num12 == userTeam || LoadData.teamDatas[num12].data_location != Global.str_location[(!isEast) ? 1 : 0])
			{
				num12 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			}
			array[num11] = num12;
		}
		return array;
	}

	public static int getParaTeam_Finals(int userTeam)
	{
		if (GameData.IsFirstFinals)
		{
			GameData.IsFirstFinals = false;
			if (GameData.FinalsTeam[0] < 15)
			{
				return 28;
			}
			return 7;
		}
		int num = UnityEngine.Random.Range(0, 100);
		int num2 = 0;
		if (num < 75)
		{
			int[] rateATeam = getRateATeam();
			num2 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			while (LoadData.teamDatas[userTeam].data_location == LoadData.teamDatas[num2].data_location)
			{
				num2 = rateATeam[UnityEngine.Random.Range(0, rateATeam.Length)];
			}
		}
		else if (num >= 75 && num < 85)
		{
			int[] rateBTeam = getRateBTeam();
			num2 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			while (LoadData.teamDatas[userTeam].data_location == LoadData.teamDatas[num2].data_location)
			{
				num2 = rateBTeam[UnityEngine.Random.Range(0, rateBTeam.Length)];
			}
		}
		else if (num >= 85 && num < 93)
		{
			int[] rateCTeam = getRateCTeam();
			num2 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			while (LoadData.teamDatas[userTeam].data_location == LoadData.teamDatas[num2].data_location)
			{
				num2 = rateCTeam[UnityEngine.Random.Range(0, rateCTeam.Length)];
			}
		}
		else
		{
			int[] rateDTeam = getRateDTeam();
			num2 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			while (LoadData.teamDatas[userTeam].data_location == LoadData.teamDatas[num2].data_location)
			{
				num2 = rateDTeam[UnityEngine.Random.Range(0, rateDTeam.Length)];
			}
		}
		return num2;
	}

	public static int[] getParaTeam_WorldCup()
	{
		int[] array = new int[7]
		{
			-1,
			-1,
			-1,
			-1,
			-1,
			-1,
			-1
		};
		int[] array2 = new int[7]
		{
			32,
			33,
			34,
			35,
			36,
			37,
			38
		};
		for (int i = 0; i < 7; i++)
		{
			int num = UnityEngine.Random.Range(0, 7);
			while (array[num] != -1)
			{
				num = UnityEngine.Random.Range(0, 7);
			}
			array[num] = array2[i];
		}
		return array;
	}

	public static int[] getRateATeam()
	{
		if (rateA_IndexInTeamData != null)
		{
			return rateA_IndexInTeamData;
		}
		rateA_IndexInTeamData = new int[6];
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (LoadData.teamDatas[i].data_rate == "A")
			{
				rateA_IndexInTeamData[num++] = i;
			}
		}
		return rateA_IndexInTeamData;
	}

	public static int[] getRateBTeam()
	{
		if (rateB_IndexInTeamData != null)
		{
			return rateB_IndexInTeamData;
		}
		rateB_IndexInTeamData = new int[7];
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (LoadData.teamDatas[i].data_rate == "B")
			{
				rateB_IndexInTeamData[num++] = i;
			}
		}
		return rateB_IndexInTeamData;
	}

	public static int[] getRateCTeam()
	{
		if (rateC_IndexInTeamData != null)
		{
			return rateC_IndexInTeamData;
		}
		rateC_IndexInTeamData = new int[8];
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (LoadData.teamDatas[i].data_rate == "C")
			{
				rateC_IndexInTeamData[num++] = i;
			}
		}
		return rateC_IndexInTeamData;
	}

	public static int[] getRateDTeam()
	{
		if (rateD_IndexInTeamData != null)
		{
			return rateD_IndexInTeamData;
		}
		rateD_IndexInTeamData = new int[9];
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (LoadData.teamDatas[i].data_rate == "D")
			{
				rateD_IndexInTeamData[num++] = i;
			}
		}
		return rateD_IndexInTeamData;
	}

	public static int[] getRateSTeam()
	{
		if (rateS_IndexInTeamData != null)
		{
			return rateS_IndexInTeamData;
		}
		rateS_IndexInTeamData = new int[2];
		int num = 0;
		for (int i = 0; i < 32; i++)
		{
			if (LoadData.teamDatas[i].data_rate == "S")
			{
				rateS_IndexInTeamData[num++] = i;
			}
		}
		return rateS_IndexInTeamData;
	}

	public static bool SimulateNPCGameResult(string rate1, string rate2, int level1, int level2, CardType type1, CardType type2)
	{
		int num = 0;
		int num2 = 0;
		if (rate1 == "A")
		{
			num = 4;
		}
		else if (rate1 == "B")
		{
			num = 3;
		}
		else if (rate1 == "C")
		{
			num = 2;
		}
		else if (rate1 == "D")
		{
			num = 1;
		}
		if (rate2 == "A")
		{
			num2 = 4;
		}
		else if (rate2 == "B")
		{
			num2 = 3;
		}
		else if (rate2 == "C")
		{
			num2 = 2;
		}
		else if (rate2 == "D")
		{
			num2 = 1;
		}
		if (num > num2)
		{
			num = 15 * (num - num2);
			num2 = 0;
		}
		else if (num < num2)
		{
			num = 0;
			num2 = 15 * (num2 - num);
		}
		else
		{
			num = 0;
			num2 = 0;
		}
		int num3 = 5 * level1;
		int num4 = 5 * level2;
		int num5 = 10;
		int num6 = 10;
		if ((type1 == CardType.CONTROL && type2 == CardType.OFFENSIVE) || (type1 == CardType.OFFENSIVE && type2 == CardType.BALANCE) || (type1 == CardType.BALANCE && type2 == CardType.CONTROL))
		{
			num5 = 10;
			num6 = 0;
		}
		else if ((type2 == CardType.CONTROL && type1 == CardType.OFFENSIVE) || (type2 == CardType.OFFENSIVE && type1 == CardType.BALANCE) || (type2 == CardType.BALANCE && type1 == CardType.CONTROL))
		{
			num5 = 10;
			num6 = 0;
		}
		int num7 = num + num3 + num5;
		int num8 = num2 + num4 + num6;
		if (UnityEngine.Random.Range(0, num7 + num8 + 1) < num7)
		{
			return true;
		}
		return false;
	}

	public static int[] getCoachAdd(bool isGemAdd)
	{
		int[] array = new int[8];
		while (true)
		{
			int num = UnityEngine.Random.Range(1, 5);
			for (int i = 0; i < num; i++)
			{
				int num2 = UnityEngine.Random.Range(0, 8);
				while (array[num2] != 0 || num2 == 3 || num2 == 7)
				{
					num2 = UnityEngine.Random.Range(0, 8);
				}
				array[num2] = UnityEngine.Random.Range(1, 6);
			}
			if ((MathHelper.getArraySum(array) > 9 && !isGemAdd) || (isGemAdd && MathHelper.getArraySum(array) > 15))
			{
				for (int j = 0; j < 8; j++)
				{
					array[j] = 0;
				}
				continue;
			}
			break;
		}
		return array;
	}

	public static bool isWeekend_Shop()
	{
		return DateTime.Now.DayOfWeek == DayOfWeek.Sunday;
	}

	public static bool isYestaodayWeekend_Shop()
	{
		return DateTime.Now.DayOfWeek == DayOfWeek.Monday;
	}

	public static bool isNextDay_Shop()
	{
		if (GameData.TimeOfShopDay == 0)
		{
			GameData.TimeOfShopDay = DateTime.Now.DayOfYear;
			return false;
		}
		if (DateTime.Now.DayOfYear != GameData.TimeOfShopDay)
		{
			GameData.TimeOfShopDay = DateTime.Now.DayOfYear;
			return true;
		}
		return false;
	}

	public static bool isNextDay_TimeBonus()
	{
		if (GameData.TimeOfTimeBonusDay == 0)
		{
			GameData.TimeOfTimeBonusDay = DateTime.Now.DayOfYear;
			return false;
		}
		if (DateTime.Now.DayOfYear != GameData.TimeOfTimeBonusDay)
		{
			GameData.TimeOfTimeBonusDay = DateTime.Now.DayOfYear;
			GameData.ADGemCount = 0;
			return true;
		}
		return false;
	}

	public static void DismissDialog(MonoBehaviour go)
	{
		if (!(go == null))
		{
			DialogDismissListener component = go.GetComponent<DialogDismissListener>();
			if (component != null && !component.IsDismissing())
			{
				component.enabled = true;
				component.Dismiss();
			}
		}
	}
}
